Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
Ways to get parsed/compiled string from a string containing HTML code | React

I have a string with HTML tags in it and I have to render the final compiled string as output.

Example:

export default function Example(props) {
  //Suppose values are {query1: "Hello", query2: "World"}
  const someMessage = `You searched for: <b>${query1}</b> and <b>${query2}</b>.`

  return (
    <div>{someMessage}</div>
  )
}

Output I'm getting: You searched for: <b>Hello</b> and <b>World</b>.

Expected Output: You searched for: Hello and World.

I am searching for an alternative other than the below one:

<div dangerouslySetInnerHTML={{__html: someMessage}} />;

Like a custom logic which can compile the HTML and return the formatted/required string

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda